package com.cqkjxy.service;

import com.cqkjxy.commons.services.AbstractService;
import com.cqkjxy.dao.StaffDao;
import com.cqkjxy.entity.StaffEntity;
import com.cqkjxy.repositories.StaffRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service

public class StaffService extends AbstractService<StaffEntity, StaffRepository, StaffDao> {

    @Autowired
    private StaffDao staffDao;

    @Override
    protected StaffDao getDao() {
        return staffDao;
    }

    @Transactional(readOnly = false)
    public int save(StaffEntity staffEntity) {
        return staffDao.createOrSave(staffEntity).getPkId();
    }

    public Iterable<StaffEntity> findAll() {
        return staffDao.findAllOrderByDefault();
    }

    @Transactional
    public void deleteRelation(int id){
        staffDao.deleteRelation(id);
    }

}
